﻿<%@ WebHandler Language="C#" Class="wxMiniProgramLogin" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
using System.Collections;

public class wxMiniProgramLogin : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string openid = context.Request.Headers["X-ACCESS-USER"];//Header中的token

        var orderid =context.Request.Form["oid"];
        int OID = int.Parse(orderid);

        //{"code":1,"msg":"订单详情","time":"1607338793","data":{"id":1987,"type":"goods","order_sn":"202006595254686321053030","user_id":5303,"activity_type":"","goods_amount":"128.00","dispatch_amount":"55.00","phone":"13378719129","consignee":"李锋","province_name":"河北省","city_name":"石家庄市","area_name":"桥西区","address":"l;klljj","province_id":130000,"city_id":130100,"area_id":130104,"status":0,"memo":null,"remark":"","total_amount":"183.00","score_amount":0,"total_fee":"183.00","discount_fee":"0.00","coupon_fee":"0.00","pay_fee":"0.00","score_fee":0,"goods_original_amount":"260.00","coupons_id":0,"transaction_id":null,"payment_json":null,"pay_type":null,"paytime":null,"ext":"{\"buy_type\":\"alone\",\"groupon_id\":0,\"expired_time\":1607339692}","platform":"H5","createtime":1607338792,"item":[{"id":2137,"user_id":5303,"order_id":1987,"goods_id":5,"goods_type":"normal","goods_sku_price_id":5,"activity_id":0,"activity_type":null,"item_goods_sku_price_id":0,"goods_sku_text":null,"goods_title":"迪奥修护精华水","goods_image":"https:\/\/api.7wpp.com\/uploads\/20200930\/b099332c172a27d60f87c15056a18bde.jpg","goods_original_price":"260.00","discount_fee":"0.00","goods_price":"128.00","goods_num":1,"dispatch_status":0,"dispatch_fee":"55.00","dispatch_type":"express","dispatch_id":8,"store_id":0,"aftersale_status":0,"comment_status":0,"refund_status":0,"refund_fee":null,"refund_msg":null,"express_name":null,"express_code":null,"express_no":null,"ext":"[]","status_code":"nopay","status_name":"","status_desc":"","btns":[],"ext_arr":[],"status_text":""}],"status_code":"nopay","status_name":"待付款","status_desc":"等待买家付款","btns":["cancel","pay"],"ext_arr":{"buy_type":"alone","groupon_id":0,"expired_time":1607339692}}}

        var code = 1;
        var msg = "订单详情";
        var time = DateTime.Now;
        using (Entities bll = new Entities())
        {
            S_Order order = new S_Order();

            if(order!=null)
                order = bll.S_Order.SingleOrDefault(x => x.OrderID == OID);

            var mytime = Utils.GetTimeStamp(Convert.ToDateTime(order.OendTime)).ToString();

            var mnews = bll.S_Order.Where(p => p.OParentId == OID || p.OrderID == OID).ToList();//全部
            ArrayList lisitem = new ArrayList();
            foreach (var xx in mnews)
            {
                lisitem.Add(new
                {
                    id = xx.OrderID,
                    goods_image = xx.SPImgUrl,
                    goods_title = xx.SPName,
                    goods_price = xx.SPrice,
                    pay_price=xx.SPrice,
                    goods_num=xx.ONumber
                });

            }

            var data = new
            {
                city_name = order.OCity,
                area_name = order.ODistrict,
                address = order.OAddress,
                addressname=order.OPeople,
                addresstel=order.OTel,
                addressRemarks=order.ORemarks,


                createtime=order.OCreatTime,
                total_fee =_rky.getSordeSumMoney(order.OrderID.ToString()),
                id = order.OrderID,
                OState = order.OState,
                order_sn = order.OOrderNumber,
                item = lisitem,
                express_fee=order.OpostPrice,
       


            };

            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time,data}));

        }

        HttpContext.Current.Response.End();

    }



    public bool IsReusable {
        get {
            return false;
        }
    }

}